<template>
  <div class="categoryChart" ref="categoryChartRef">CategoryChart</div>
</template>

<script lang="ts">
export default {
  name: "CategoryChart",
};
</script>

<script lang="ts" setup>
import * as echarts from "echarts";
import { ref, onMounted } from "vue";

const categoryChartRef = ref();
onMounted(() => {
  const myChart = echarts.init(categoryChartRef.value);
  const option = {
    series: {
      type: "pie",
      data: [
        {
          name: "粉面粥店",
          value: 55,
        },
        {
          name: "简餐便当",
          value: 45,
        },
        {
          name: "汉堡披萨",
          value: 67,
        },
        {
          name: "香锅冒菜",
          value: 60,
        },
        {
          name: "小吃炸串",
          value: 30,
        },
        {
          name: "地方菜系",
          value: 80,
        },
        {
          name: "轻食简餐",
          value: 36,
        },
      ],
      // 圆的半径
      radius: ["40%", "60%"],
      // 圆心坐标
      center: ["30%", "60%"],
      label: {
        // show: false,
        position: "inside",
      },
    },
    title: {
      text: "累计订单量",
      textStyle: {
        fontSize: 14,
      },
      subtext: "406",
      subtextStyle: {
        fontSize: 25,
      },
      left: "22%",
      top: "53%",
    },
    legend: {
      orient: "vertical",
      data: [
        "粉面粥店",
        "简餐便当",
        "轻食简餐",
        "地方菜系",
        "汉堡披萨",
        "香锅冒菜",
        "小吃炸串",
      ],
      top: "middle",
      right: "5%",
    },
  };
  myChart.setOption(option);
});
</script>

<style scoped>
.categoryChart {
  width: 100%;
  height: 385px;
}
</style>
